<template>
	<div id="app">
		<div class="tip">
			<span>注</span>由于安全因素，提现信息只能填写一次，请仔细填写；后续如需修改请联系客服。
		</div>
		<div >
			<div class="form-box">
				<div class="logo flex-xy-center">
					<img src="https://shop.zdsy.shop/themes/screens/public/assets/images/alipay.jpg">
				</div>
				<div class="item flex-box-x">
					<div class="left flex-y-center">支付宝姓名</div>
					<input v-model="alipay_name" type="text" class="col-xs-x" readonly="readonly">
				</div>
				<div class="item flex-box-x">
					<div class="left flex-y-center">支付宝账号</div>
					<input v-model="alipay_number" type="text" class="col-xs-x" readonly="readonly">
				</div>
				<div class="item upload flex-box-x">
					<div class="left">支付宝二维码</div>
					<div>
						<div class="id_card_content">
							<div class="" style="position: absolute;width: 100%;height: 100%;">
								<img class="pic" :src="alipay_bank_start" alt="">
							</div>
						</div>
					</div>
				</div>
				<div style="display:flex;justify-content: center;">
					<div class="save" @click="save(1)">保存</div>
				</div>
			</div>

			<div class="form-box" >
				<div class="logo flex-xy-center" style="border-top: .133333rem solid #f0f0f0">
					<img src="https://shop.zdsy.shop/themes/screens/public/assets/images/bank.jpg">
				</div>

				<div class="item flex-box-x">
					<div class="left flex-y-center">开户银行</div>
					<input v-model="bank_start" id="bank_start" type="text" class="col-xs-x"
						placeholder="输入开户银行">
				</div>
				<div class="item flex-box-x">
					<div class="left flex-y-center">开户姓名</div>
					<input v-model="user_name" id="user_name" type="text" class="col-xs-x" placeholder="输入开户姓名">
				</div>
				<div class="item flex-box-x">
					<div class="left flex-y-center">银行账号</div>
					<input v-model="account_number" id="bank_account" type="text" class="col-xs-x"
						placeholder="输入银行账号">
				</div>
				<div style="display:flex;justify-content: center;">
					<div class="save" @click="save(2)">保存</div>
				</div>

			</div>


		</div>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				accountList: [],
				type:1,
				alipay_name:'',
				alipay_number:'',
				alipay_bank_start:'',
				user_name:'',
				account_number:'',
				bank_start:'',
				account:[],
			};
		},
		onLoad(options) {
			this.my_account_account();
		},
		methods: {
			my_account_account() {
				this.status = 'loading';
				this.$api.get({
					url: 'portal/my/my_account_account',
					data: {
					},
					success: res => {
						console.log(res.data)
						if (res.code == 1) {
							this.accountList = res.data;
							
							this.accountList.forEach(item => {
							if (item.type=== 1) {
								    this.type = item.type;
									this.alipay_name  = item.user_name;
									this.alipay_number  = item.account_number;
									this.alipay_bank_start  = item.bank_start;
								}
							if (item.type=== 2) {
								    this.type = item.type;
									this.user_name  = item.user_name;
									this.account_number  = item.account_number;
									this.bank_start  = item.bank_start;
								}
							});
							
                           
						}
					}
				});
			},
			save(type) {
				
				if(type==1){
					this.account = {
						type:type,
						bank_start:this.alipay_bank_start,
						user_name:this.alipay_name,
						account_number:this.alipay_number
					}
				}else{
					this.account ={
						type:type,
						bank_start:this.bank_start,
						user_name:this.user_name,
						account_number:this.account_number
					}
				}
				this.$api.post({
					url: 'portal/my/deposit_account',
					data: this.account,
					success: res => {

						this.$toast(res.msg);
					}
				});
			},
		}
	};
</script>

<style>
	html,
	body {
		background: #fff;
	}

	/*横向弹性盒子*/

	.flex-box-x {
		-webkit-box-orient: horizontal;
		-webkit-box-direction: normal;
		-ms-flex-direction: row;
		flex-direction: row;
		display: -webkit-flex
	}

	.flex-box-x>.col-xs-x {
		-webkit-box-flex: 1;
		-ms-flex: 1;
		flex: 1
	}


	/*纵向弹性盒子*/

	.flex-box-y {
		-webkit-box-orient: vertical;
		-webkit-box-direction: normal;
		-ms-flex-direction: column;
		flex-direction: column;
		display: -webkit-flex
	}

	.flex-box-y>.col-xs-y {
		-webkit-box-flex: 1;
		-ms-flex: 1;
		flex: 1
	}


	/*水平居中*/

	.flex-x-center {
		-webkit-box-pack: center;
		-ms-flex-pack: center;
		justify-content: center;
		display: -webkit-flex;
		text-align: center
	}


	/*垂直居中*/

	.flex-y-center {
		-webkit-box-align: center;
		-ms-flex-align: center;
		align-items: center;
		display: -webkit-flex
	}


	/*水平垂直居中*/

	.flex-xy-center {
		-webkit-box-pack: center;
		-ms-flex-pack: center;
		justify-content: center;
		-webkit-box-align: center;
		-ms-flex-align: center;
		align-items: center;
		display: -webkit-flex;
	}


	/*顶部对齐*/

	.flex-top-center {
		-webkit-box-align: start;
		-ms-flex-align: start;
		-ms-grid-row-align: flex-start;
		align-items: flex-start;
		display: -webkit-flex;
	}


	/*底部对齐*/

	.flex-botttom-center {
		-webkit-box-align: end;
		-ms-flex-align: end;
		-ms-grid-row-align: flex-end;
		align-items: flex-end;
		display: -webkit-flex;
	}

	.tip {
		padding: .4rem;
		background: #bae5f6;
	}

	.tip span {
		display: inline-block;
		width: .666667rem;
		height: .666667rem;
		line-height: .666667rem;
		text-align: center;
		background: #f03226;
		color: #fff;
		border-radius: .08rem;
		margin-right: .133333rem
	}

	.logo {
		padding: 1rem 0;
		text-align: center;
		/* width: 100%; */
		height: 2rem;
	}

	.logo img {
		width: 6rem;
	}

	.form-box {
		padding: 0 0 .533333rem;
	}

	.form-box .item {
		height: 2.5rem;
		line-height: 2.5rem;
		padding: 0 1.4rem;
		border-bottom: 1px solid #ededed;
	}

	.form-box .item .left {
		margin-right: .266667rem;
		font-size: .346667rem;
	}

	.form-box .item input {
		border: none;
		height: 2.5rem;
		line-height: 2.5rem;
		/* font-size: .346667rem; */
	}

	.form-box .item.upload {
		height: auto;
	}

	.form-box .item.upload .left {
		height: 2.5rem;
		line-height: 1.333333rem;
	}

	.form-box .item.upload .btn {
		padding: .4rem;
		border: 1px solid #8a8a8a;
		background: #f0f0f0;
		width: 50%;
		text-align: center;
		margin: 0.4rem 0;
	}

	.form-box .item.upload .btn img {
		width: 1.333333rem;
	}

	.form-box .save {
		width: 10rem;
		background: #DF2E26;
		margin: 1rem .4rem 0;
		height: 3rem;
		line-height: 3rem;
		border-radius: .08rem;
		text-align: center;
		font-size: .4rem;
		color: #fff;
	}

	.id_card_content {
		position: relative;
		height: 6rem;
		width: 4rem;
		margin: 16px 20px;
	}

	img {
		width: 100%;
		height: 100%;
	}

	.item:last-child {
		border: none;
	}
</style>
